package com.wiki.gds.backstage.admin.controller.sys;


import com.wiki.gds.base.common.dto.ResponseDto;
import com.wiki.gds.base.common.exception.BizExceptionEnum;
import com.wiki.gds.base.common.utils.ResponseDtoFactory;
import com.wiki.gds.base.security.common.model.SecurityUser;
import com.wiki.gds.user.facade.sys.api.ResourceApi;
import com.wiki.gds.user.facade.sys.vo.vue.MenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("resource")
public class ResourceController {


    @Autowired
    ResourceApi resourceApi;

    @RequestMapping("menu")
    public ResponseDto menu(){
        ResponseDto rs= ResponseDtoFactory.GetInstance().build(BizExceptionEnum.SUCCESSFUL_OPERATION);
        SecurityUser securityUser= (SecurityUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        List<MenuVo> list= resourceApi.getMenu(securityUser.getId());
        rs.setData(list);
        return rs;
    }
}
